//cpp实现不定参可变参数
#include<iostream>
#include<cstdarg>

void MyPrintf(const char* fmt,...)
{
    va_list ap;
    va_start(ap,fmt);
    char* buf=nullptr;
    int len =vasprintf(&buf,fmt,ap);

    va_end(ap);
    std::cout<<buf<<"\n";
    std::cout<<len<<std::endl;
    free(buf);
}

int main()
{
    MyPrintf("%d-%d",10,20);

    return 0;
}